home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-k-archive.past / tex-k-archive.gz / tex-k-archive / 000405_fj@iesd.auc.dk_Wed Mar 16 19:25:36 1994.msg < prev    next >
Internet Message Format  |  1994-10-11  |  4KB

  1. Received: from iesd.auc.dk by cs.umb.edu with SMTP id AA12354
  2.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Wed, 16 Mar 1994 12:25:52 -0500
  3. Received: from loke.iesd.auc.dk (fj@loke.iesd.auc.dk [130.225.48.20]) by iesd.auc.dk (8.6.5/8.6.5) with ESMTP id SAA21104; Wed, 16 Mar 1994 18:25:41 +0100
  4. From: Frank Jensen <fj@iesd.auc.dk>
  5. Received: from localhost (fj@localhost) by loke.iesd.auc.dk (8.6.4/8.6.4) id SAA11630; Wed, 16 Mar 1994 18:25:36 +0100
  6. Date: Wed, 16 Mar 1994 18:25:36 +0100
  7. Message-Id: <199403161725.SAA11630@loke.iesd.auc.dk>
  8. To: kb@cs.umb.edu
  9. Cc: tex-k@cs.umb.edu
  10. In-Reply-To: <199403161043.AA26915@terminus.cs.umb.edu> (kb@cs.umb.edu)
  11. Subject: Re: Kpathsearch -- database searching
  12.  
  13. > It's not a function solely of the path being searched on; the program
  14. > being run is also a factor. For example, when xdvi looks for a VF file
  15. > it need not exist, but when vftovp looks for a VF file, it must exist.
  16. > When TeX does a \input, the file must exist. But when TeX does an
  17. > \openin, it need not. The same search paths are involved in each case.
  18.  
  19. I can see the need for treating the situation with a non-existing file
  20. differently in different cases.  But this should be separated from the
  21. task of determining if a file exists or not.  The library should take
  22. care of the latter task using the search strategy that has been
  23. externally specified (either trough environment variables or a
  24. specification compiled into the program or a combination of these).
  25. I would like to be able to control (in fine detail) how Kpathsearch
  26. does this searching.  This includes being able to specify whether the
  27. database should be searched or the disk should be searched (or both).
  28.  
  29. For example, my personal setup might include:
  30.  
  31.     setenv TEXINPUTS .:~/TeX/Inputs//:</usr/local/lib/texmf/tex//>
  32.  
  33. meaning: search the current directory; then search all subdirectories
  34. of ~/TeX/Inputs (but don't bother to look in the db, since you won't
  35. find anything relevant about this hierarchy in it); finally, check the
  36. db for files in the hierarchy rooted at /usr/local/lib/texmf/tex (but
  37. don't search the disk, because I'm too impatient too wait -- just
  38. report it if you don't find anything in the db).
  39.  
  40. [In practice, the first two components would be specified directly by
  41. me (as a user), while the last component would be compiled into the
  42. program by me (as an installer).]
  43.  
  44. It is extremely easy to modify Kpathsearch to behave as described here
  45. (you have already done 99% of the work).  Here is the rest in the form
  46. of a modified version of the `path_search' function from "pathsearch.c":
  47.  
  48. /* This is the hard case -- look for NAME in PATH.  If
  49.    ALL is false, just return the first file found.  Otherwise,
  50.    search all elements of PATH.  */
  51.  
  52. static str_list_type
  53. path_search P3C(const_string, path,  string, name,  boolean, all)
  54. {
  55.   str_list_type ret_list = str_list_init ();
  56.   string elt;
  57.  
  58.   for (elt = kpse_path_element (path); elt; elt = kpse_path_element (NULL))
  59.     {
  60.       str_list_type found = str_list_init ();
  61.  
  62.       if (elt[0] == '<' && elt[strlen (elt) - 1] == '>') /* Search the db. */
  63.     found = kpse_db_search (name, elt, all);
  64.     /* We expect `kpse_db_search' (or rather its `match' operation)
  65.        to handle the angle brackets correctly.  */
  66.       else /* Search the disk. */
  67.         {
  68.           str_llist_type *dirs = kpse_element_dirs (elt);
  69.           if (dirs && *dirs)
  70.             found = dir_list_search (dirs, name, all);
  71.         }
  72.  
  73.         /* Did we find anything?  */
  74.         if (STR_LIST (found))
  75.           if (all)
  76.             str_list_concat (&ret_list, found);
  77.           else
  78.             {
  79.               str_list_add (&ret_list, STR_LIST_ELT (found, 0));
  80.               break;
  81.             }
  82.     }
  83.  
  84.   /* Free the expanded name we were passed.  It can't be in the return
  85.      list, since the path directories got unconditionally prepended.  */
  86.   free (name);
  87.   
  88.   return ret_list;
  89. }      
  90.  
  91. /Frank